home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / bison / bison.simple < prev   
Text File  |  1988-12-29  |  16KB  |  558 lines

  1. #line 2 "bison.simple"
  2.  
  3. /* Skeleton output parser for bison,
  4.    copyright (C) 1984 Bob Corbett and Richard Stallman
  5.  
  6.                NO WARRANTY
  7.  
  8.   BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  9. NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  10. WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  11. RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  12. WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  13. BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  14. FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  15. AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  16. DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  17. CORRECTION.
  18.  
  19.  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  20. STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  21. WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  22. LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  23. OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  24. USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  25. DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  26. A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  27. PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  28. DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  29.  
  30.         GENERAL PUBLIC LICENSE TO COPY
  31.  
  32.   1. You may copy and distribute verbatim copies of this source file
  33. as you receive it, in any medium, provided that you conspicuously and
  34. appropriately publish on each copy a valid copyright notice "Copyright
  35. (C) 1985 Free Software Foundation, Inc."; and include following the
  36. copyright notice a verbatim copy of the above disclaimer of warranty
  37. and of this License.  You may charge a distribution fee for the
  38. physical act of transferring a copy.
  39.  
  40.   2. You may modify your copy or copies of this source file or
  41. any portion of it, and copy and distribute such modifications under
  42. the terms of Paragraph 1 above, provided that you also do the following:
  43.  
  44.     a) cause the modified files to carry prominent notices stating
  45.     that you changed the files and the date of any change; and
  46.  
  47.     b) cause the whole of any work that you distribute or publish,
  48.     that in whole or in part contains or is a derivative of this
  49.     program or any part thereof, to be licensed at no charge to all
  50.     third parties on terms identical to those contained in this
  51.     License Agreement (except that you may choose to grant more extensive
  52.     warranty protection to some or all third parties, at your option).
  53.  
  54.     c) You may charge a distribution fee for the physical act of
  55.     transferring a copy, and you may at your option offer warranty
  56.     protection in exchange for a fee.
  57.  
  58. Mere aggregation of another unrelated program with this program (or its
  59. derivative) on a volume of a storage or distribution medium does not bring
  60. the other program under the scope of these terms.
  61.  
  62.   3. You may copy and distribute this program (or a portion or derivative
  63. of it, under Paragraph 2) in object code or executable form under the terms
  64. of Paragraphs 1 and 2 above provided that you also do one of the following:
  65.  
  66.     a) accompany it with the complete corresponding machine-readable
  67.     source code, which must be distributed under the terms of
  68.     Paragraphs 1 and 2 above; or,
  69.  
  70.     b) accompany it with a written offer, valid for at least three
  71.     years, to give any third party free (except for a nominal
  72.     shipping charge) a complete machine-readable copy of the
  73.     corresponding source code, to be distributed under the terms of
  74.     Paragraphs 1 and 2 above; or,
  75.  
  76.     c) accompany it with the information you received as to where the
  77.     corresponding source code may be obtained.  (This alternative is
  78.     allowed only for noncommercial distribution and only if you
  79.     received the program in object code or executable form alone.)
  80.  
  81. For an executable file, complete source code means all the source code for
  82. all modules it contains; but, as a special exception, it need not include
  83. source code for modules which are standard libraries that accompany the
  84. operating system on which the executable file runs.
  85.  
  86.   4. You may not copy, sublicense, distribute or transfer this program
  87. except as expressly provided under this License Agreement.  Any attempt
  88. otherwise to copy, sublicense, distribute or transfer this program is void and
  89. your rights to use the program under this License agreement shall be
  90. automatically terminated.  However, parties who have received computer
  91. software programs from you with this License Agreement will not have
  92. their licenses terminated so long as such parties remain in full compliance.
  93.  
  94.   5. If you wish to incorporate parts of this program into other free
  95. programs whose distribution conditions are different, write to the Free
  96. Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  97. worked out a simple rule that can be stated here, but we will often permit
  98. this.  We will be guided by the two goals of preserving the free status of
  99. all derivatives of our free software and of promoting the sharing and reuse of
  100. software.
  101.  
  102.  
  103. In other words, you are welcome to use, share and improve this program.
  104. You are forbidden to forbid anyone else to use, share and improve
  105. what you give them.   Help stamp out software-hoarding!  */
  106.  
  107. /* This is the parser code that is written into each bison parser
  108.   when the %semantic_parser declaration is not specified in the grammar.
  109.   It was written by Richard Stallman by simplifying the hairy parser
  110.   used when %semantic_parser is specified.  */
  111.  
  112. /* Note: there must be only one dollar sign in this file.
  113.    It is replaced by the list of actions, each action
  114.    as one case of the switch.  */
  115.  
  116. #define yyerrok        (yyerrstatus = 0)
  117. #define yyclearin    (yychar = YYEMPTY)
  118. #define YYEMPTY        -2
  119. #define YYEOF        0
  120. #define YYFAIL        goto yyerrlab;
  121.  
  122. #define YYTERROR    1
  123.  
  124. #ifndef YYIMPURE
  125. #define YYLEX        yylex()
  126. #endif
  127.  
  128. #ifndef YYPURE
  129. #define YYLEX        yylex(&yylval, &yylloc)
  130. #endif
  131.  
  132. /* If nonreentrant, generate the variables here */
  133.  
  134. #ifndef YYIMPURE
  135.  
  136. int    yychar;            /*  the lookahead symbol        */
  137. YYSTYPE    yylval;            /*  the semantic value of the        */
  138.                 /*  lookahead symbol            */
  139.  
  140. YYLTYPE yylloc;            /*  location data for the lookahead    */
  141.                 /*  symbol                */
  142.  
  143. int yynerr;            /*  number of parse errors so far       */
  144.  
  145. #ifdef YYDEBUG
  146. int yydebug = 0;        /*  nonzero means print parse trace    */
  147. #endif
  148.  
  149. #endif  /* YYIMPURE */
  150.  
  151.  
  152. /*  YYMAXDEPTH indicates the initial size of the parser's stacks    */
  153.  
  154. #ifndef    YYMAXDEPTH
  155. #define YYMAXDEPTH 200
  156. #endif
  157.  
  158. /*  YYMAXLIMIT is the maximum size the stacks can grow to
  159.     (effective only if the built-in stack extension method is used).  */
  160.  
  161. #ifndef YYMAXLIMIT
  162. #define YYMAXLIMIT 10000
  163. #endif
  164.  
  165.  
  166. #line 167 "bison.simple"
  167. int
  168. yyparse()
  169. {
  170.   register int yystate;
  171.   register int yyn;
  172.   register short *yyssp;
  173.   register YYSTYPE *yyvsp;
  174.   YYLTYPE *yylsp;
  175.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  176.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  177.  
  178.   short    yyssa[YYMAXDEPTH];    /*  the state stack            */
  179.   YYSTYPE yyvsa[YYMAXDEPTH];    /*  the semantic value stack        */
  180.   YYLTYPE yylsa[YYMAXDEPTH];    /*  the location stack            */
  181.  
  182.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  183.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  184.   YYLTYPE *yyls = yylsa;
  185.  
  186.   int yymaxdepth = YYMAXDEPTH;
  187.  
  188. #ifndef YYPURE
  189.   int yychar;
  190.   YYSTYPE yylval;
  191.   YYLTYPE yylloc;
  192. #endif
  193.  
  194. #ifdef YYDEBUG
  195.   extern int yydebug;
  196. #endif
  197.  
  198.  
  199.   YYSTYPE yyval;        /*  the variable used to return        */
  200.                 /*  semantic values from the action    */
  201.                 /*  routines                */
  202.  
  203.   int yylen;
  204.  
  205. #ifdef YYDEBUG
  206.   if (yydebug)
  207.     fprintf(stderr, "Starting parse\n");
  208. #endif
  209.  
  210.   yystate = 0;
  211.   yyerrstatus = 0;
  212.   yynerr = 0;
  213.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  214.  
  215.   /* Initialize stack pointers.
  216.      Waste one element of value and location stack
  217.      so that they stay on the same level as the state stack.  */
  218.  
  219.   yyssp = yyss - 1;
  220.   yyvsp = yyvs;
  221.   yylsp = yyls;
  222.  
  223. /* Push a new state, which is found in  yystate  .  */
  224. /* In all cases, when you get here, the value and location stacks
  225.    have just been pushed. so pushing a state here evens the stacks.  */
  226. yynewstate:
  227.  
  228.   *++yyssp = yystate;
  229.  
  230.   if (yyssp >= yyss + yymaxdepth - 1)
  231.     {
  232.       /* Give user a chance to reallocate the stack */
  233.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  234.       YYSTYPE *yyvs1 = yyvs;
  235.       YYLTYPE *yyls1 = yyls;
  236.       short *yyss1 = yyss;
  237.  
  238.       /* Get the current used size of the three stacks, in elements.  */
  239.       int size = yyssp - yyss + 1;
  240.  
  241. #ifdef yyoverflow
  242.       /* Each stack pointer address is followed by the size of
  243.      the data in use in that stack, in bytes.  */
  244.       yyoverflow("parser stack overflow",
  245.          &yyss1, size * sizeof (*yyssp),
  246.          &yyvs1, size * sizeof (*yyvsp),
  247.          &yyls1, size * sizeof (*yylsp),
  248.          &yymaxdepth);
  249.  
  250.       yyss = yyss1; yyvs = yyvs1; yyls = yyls1;
  251. #else /* no yyoverflow */
  252.       /* Extend the stack our own way.  */
  253.       if (yymaxdepth >= YYMAXLIMIT)
  254.     yyerror("parser stack overflow");
  255.       yymaxdepth *= 2;
  256.       if (yymaxdepth > YYMAXLIMIT)
  257.     yymaxdepth = YYMAXLIMIT;
  258.       yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp));
  259.       bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  260.       yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp));
  261.       bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  262. #ifdef YYLSP_NEEDED
  263.       yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp));
  264.       bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  265. #endif
  266. #endif /* no yyoverflow */
  267.  
  268.       yyssp = yyss + size - 1;
  269.       yyvsp = yyvs + size - 1;
  270. #ifdef YYLSP_NEEDED
  271.       yylsp = yyls + size - 1;
  272. #endif
  273.  
  274. #ifdef YYDEBUG
  275.       if (yydebug)
  276.     fprintf(stderr, "Stack size increased to %d\n", yymaxdepth);
  277. #endif
  278.  
  279.       if (yyssp >= yyss + yymaxdepth - 1)
  280.     YYABORT;
  281.     }
  282.  
  283. #ifdef YYDEBUG
  284.   if (yydebug)
  285.     fprintf(stderr, "Entering state %d\n", yystate);
  286. #endif
  287.  
  288. /* Do appropriate processing given the current state.  */
  289. /* Read a lookahead token if we need one and don't already have one.  */
  290. yyresume:
  291.  
  292.   /* First try to decide what to do without reference to lookahead token.  */
  293.  
  294.   yyn = yypact[yystate];
  295.   if (yyn == YYFLAG)
  296.     goto yydefault;
  297.  
  298.   /* Not known => get a lookahead token if don't already have one.  */
  299.  
  300.   /* yychar is either YYEMPTY or YYEOF
  301.      or a valid token in external form.  */
  302.  
  303.   if (yychar == YYEMPTY)
  304.     {
  305. #ifdef YYDEBUG
  306.       if (yydebug)
  307.     fprintf(stderr, "Reading a token: ");
  308. #endif
  309.       yychar = YYLEX;
  310.     }
  311.  
  312.   /* Convert token to internal form (in yychar1) for indexing tables with */
  313.  
  314.   if (yychar <= 0)        /* This means end of input. */
  315.     {
  316.       yychar1 = 0;
  317.       yychar = YYEOF;        /* Don't call YYLEX any more */
  318.  
  319. #ifdef YYDEBUG
  320.       if (yydebug)
  321.     fprintf(stderr, "Now at end of input.\n");
  322. #endif
  323.     }
  324.   else
  325.     {
  326.       yychar1 = YYTRANSLATE(yychar);
  327.  
  328. #ifdef YYDEBUG
  329.       if (yydebug)
  330.     fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]);
  331. #endif
  332.     }
  333.  
  334.   yyn += yychar1;
  335.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  336.     goto yydefault;
  337.  
  338.   yyn = yytable[yyn];
  339.  
  340.   /* yyn is what to do for this token type in this state.
  341.      Negative => reduce, -yyn is rule number.
  342.      Positive => shift, yyn is new state.
  343.        New state is final state => don't bother to shift,
  344.        just return success.
  345.      0, or most negative number => error.  */
  346.  
  347.   if (yyn < 0)
  348.     {
  349.       if (yyn == YYFLAG)
  350.     goto yyerrlab;
  351.       yyn = -yyn;
  352.       goto yyreduce;
  353.     }
  354.   else if (yyn == 0)
  355.     goto yyerrlab;
  356.  
  357.   if (yyn == YYFINAL)
  358.     YYACCEPT;
  359.  
  360.   /* Shift the lookahead token.  */
  361.  
  362. #ifdef YYDEBUG
  363.   if (yydebug)
  364.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  365. #endif
  366.  
  367.   /* Discard the token being shifted unless it is eof.  */
  368.   if (yychar != YYEOF)
  369.     yychar = YYEMPTY;
  370.  
  371.   *++yyvsp = yylval;
  372. #ifdef YYLSP_NEEDED
  373.   *++yylsp = yylloc;
  374. #endif
  375.  
  376.   /* count tokens shifted since error; after three, turn off error status.  */
  377.   if (yyerrstatus) yyerrstatus--;
  378.  
  379.   yystate = yyn;
  380.   goto yynewstate;
  381.  
  382. /* Do the default action for the current state.  */
  383. yydefault:
  384.  
  385.   yyn = yydefact[yystate];
  386.   if (yyn == 0)
  387.     goto yyerrlab;
  388.  
  389. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  390. yyreduce:
  391.   yylen = yyr2[yyn];
  392.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  393.  
  394. #ifdef YYDEBUG
  395.   if (yydebug)
  396.     {
  397.       if (yylen == 1)
  398.     fprintf (stderr, "Reducing 1 value via line %d, ",
  399.          yyrline[yyn]);
  400.       else
  401.     fprintf (stderr, "Reducing %d values via line %d, ",
  402.          yylen, yyrline[yyn]);
  403.     }
  404. #endif
  405.  
  406. $   /* the action file gets copied in in place of this dollarsign */
  407. #line 408 "bison.simple"
  408.  
  409.   yyvsp -= yylen;
  410.   yyssp -= yylen;
  411. #ifdef YYLSP_NEEDED
  412.   yylsp -= yylen;
  413. #endif
  414.  
  415. #ifdef YYDEBUG
  416.   if (yydebug)
  417.     {
  418.       short *ssp1 = yyss - 1;
  419.       fprintf (stderr, "state stack now");
  420.       while (ssp1 != yyssp)
  421.     fprintf (stderr, " %d", *++ssp1);
  422.       fprintf (stderr, "\n");
  423.     }
  424. #endif
  425.  
  426.   *++yyvsp = yyval;
  427.  
  428. #ifdef YYLSP_NEEDED
  429.   yylsp++;
  430.   if (yylen == 0)
  431.     {
  432.       yylsp->first_line = yylloc.first_line;
  433.       yylsp->first_column = yylloc.first_column;
  434.       yylsp->last_line = (yylsp-1)->last_line;
  435.       yylsp->last_column = (yylsp-1)->last_column;
  436.       yylsp->text = 0;
  437.     }
  438.   else
  439.     {
  440.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  441.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  442.     }
  443. #endif
  444.  
  445.   /* Now "shift" the result of the reduction.
  446.      Determine what state that goes to,
  447.      based on the state we popped back to
  448.      and the rule number reduced by.  */
  449.  
  450.   yyn = yyr1[yyn];
  451.  
  452.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  453.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  454.     yystate = yytable[yystate];
  455.   else
  456.     yystate = yydefgoto[yyn - YYNTBASE];
  457.  
  458.   goto yynewstate;
  459.  
  460. yyerrlab:   /* here on detecting error */
  461.  
  462.   if (! yyerrstatus)
  463.     /* If not already recovering from an error, report this error.  */
  464.     {
  465.       ++yynerr;
  466.       yyerror("parse error");
  467.     }
  468.  
  469.   if (yyerrstatus == 3)
  470.     {
  471.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  472.  
  473.       /* return failure if at end of input */
  474.       if (yychar == YYEOF)
  475.     YYABORT;
  476.  
  477. #ifdef YYDEBUG
  478.       if (yydebug)
  479.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  480. #endif
  481.  
  482.       yychar = YYEMPTY;
  483.     }
  484.  
  485.   /* Else will try to reuse lookahead token
  486.      after shifting the error token.  */
  487.  
  488.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  489.  
  490.   goto yyerrhandle;
  491.  
  492. yyerrdefault:  /* current state does not do anything special for the error token. */
  493.  
  494. #if 0
  495.   /* This is wrong; only states that explicitly want error tokens
  496.      should shift them.  */
  497.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  498.   if (yyn) goto yydefault;
  499. #endif
  500.  
  501. yyerrpop:   /* pop the current state because it cannot handle the error token */
  502.  
  503.   if (yyssp == yyss) YYABORT;
  504.   yyvsp--;
  505.   yystate = *--yyssp;
  506. #ifdef YYLSP_NEEDED
  507.   yylsp--;
  508. #endif
  509.  
  510. #ifdef YYDEBUG
  511.   if (yydebug)
  512.     {
  513.       short *ssp1 = yyss - 1;
  514.       fprintf (stderr, "Error: state stack now");
  515.       while (ssp1 != yyssp)
  516.     fprintf (stderr, " %d", *++ssp1);
  517.       fprintf (stderr, "\n");
  518.     }
  519. #endif
  520.  
  521. yyerrhandle:
  522.  
  523.   yyn = yypact[yystate];
  524.   if (yyn == YYFLAG)
  525.     goto yyerrdefault;
  526.  
  527.   yyn += YYTERROR;
  528.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  529.     goto yyerrdefault;
  530.  
  531.   yyn = yytable[yyn];
  532.   if (yyn < 0)
  533.     {
  534.       if (yyn == YYFLAG)
  535.     goto yyerrpop;
  536.       yyn = -yyn;
  537.       goto yyreduce;
  538.     }
  539.   else if (yyn == 0)
  540.     goto yyerrpop;
  541.  
  542.   if (yyn == YYFINAL)
  543.     YYACCEPT;
  544.  
  545. #ifdef YYDEBUG
  546.   if (yydebug)
  547.     fprintf(stderr, "Shifting error token, ");
  548. #endif
  549.  
  550.   *++yyvsp = yylval;
  551. #ifdef YYLSP_NEEDED
  552.   *++yylsp = yylloc;
  553. #endif
  554.  
  555.   yystate = yyn;
  556.   goto yynewstate;
  557. }
  558.